package com.fang.controller;

import com.fang.service.PushService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Fang Ruichuan
 * @date 2022-10-07 15:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/push")
public class PushController {

    private final PushService pushService;

    // 推送给所有用户
    @PostMapping("/pushAll")
    public void pushMsgToAll(@RequestParam("msg") String msg) {
        pushService.pushMsgToAll(msg);
    }

    // 推送给指定用户
    @PostMapping("/pushOne")
    public void pushMsgToOne(@RequestParam("userId") String userId, @RequestParam("msg") String msg) {
        pushService.pushMsgToOne(userId, msg);
    }
}
